# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=radvd
pkgver=2.19
pkgrel=4
pkgdesc="IPv6 router advertisement daemon"
url="http://www.litech.org/radvd"
arch="all"
license="BSD-Advertising-Acknowledgement"
makedepends="flex bison libdaemon-dev linux-headers check-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="http://www.litech.org/radvd/dist/radvd-$pkgver.tar.xz
	radvd.initd
	radvd.confd
	fix-alpine-plz.patch
	"

# test failure on builders due to kernel issue
case "$CARCH" in
mips*)	options="!check";;
esac

prepare() {
 	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc/ \
		--with-check \
		--with-pidfile=/run/radvd/radvd.pid
	# work around parallel build issue
	make gram.h && make
}

check() {
	make -C "$builddir" check
}

package() {
	make -j1 DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/radvd.initd "$pkgdir"/etc/init.d/radvd
	install -Dm644 "$srcdir"/radvd.confd "$pkgdir"/etc/conf.d/radvd
	install -Dm644 radvd.conf.example \
		"$pkgdir"/usr/share/doc/radvd/radvd.conf.example
}

sha512sums="
a1eb40af90fc83ebab2517c16a0f7e85c11338ab276bec400b7c33177748d1e36bc5abd7e373b6742f12f7c690dd7ae6b951bc832c7de9bbb56f7e9bc844ed22  radvd-2.19.tar.xz
fd78249b8ae25d1c55fc0b5cc2b3dd202388c0ca7be2737ecbd33ed5cd3c8616858aa46350967350fe8e8c0032552126918c8b9c36b13d799f3c5d8fb576fdf8  radvd.initd
31cca1d48e5f0c4fe96a7a32ca6339e7aa9e478f7e9086f05bbc79ca59b1637d99e46079d7be77ef717a8fb975fada7664058e3bc61117309025b72f3e87d294  radvd.confd
dffe4167c54c430fc38953e70d546fdf443944eceee4c610f14d63947fe8c04960b48a8acf5742edf8721558c4b811c9a4033ad9abe787ead9cc1bb0721b654c  fix-alpine-plz.patch
"
